// $Id: Player.cpp 128 2007-11-17 15:49:11Z bram $


/**
 * Player class definition.
 *
 * @file Player.cpp
 * @author Wim Leers
 * @author Bram Bonn&eacute;
 */


#include "Player.h"


//----------------------------------------------------------------------------
// Constructor & copy constructor.

Player::Player(string name, int plays, int victories) {
	m_name = name;
	NameToLower();
	m_plays = plays;
	m_victories = victories;
}

Player::Player(const Player & other) {
	m_name = other.m_name;
	m_plays = other.m_plays;
	m_victories = other.m_victories;
}

float Player::GetPercent(void) const{
	if (m_plays > 0)
		return (m_victories*1.0) / m_plays;
	else
		return 0;
}

//----------------------------------------------------------------------------
// Private methods.

void Player::NameToLower(void) {
	for (unsigned int i = 0; i < m_name.length(); i++)
		m_name[i] = tolower(m_name[i]);
}
